program nlelas
	version 11
	syntax varlist(min=19 max=41) [aw fw iw] if, at(name)

	local elas: word 1 of `varlist'
	local v1: word 2 of `varlist'
	local v2: word 3 of `varlist'
	local v3: word 4 of `varlist'
	local v4: word 5 of `varlist'
	local v5: word 6 of `varlist'
	local v6: word 7 of `varlist'
	local v7: word 8 of `varlist'
	local v8: word 9 of `varlist'
	local v9: word 10 of `varlist'
	local v10: word 11 of `varlist'
	local v11: word 12 of `varlist'
	local v12: word 13 of `varlist'
	local v13: word 14 of `varlist'
	local v14: word 15 of `varlist'
	local v15: word 16 of `varlist'
	local v16: word 17 of `varlist'
	local v17: word 18 of `varlist'
	local v18: word 19 of `varlist'
	local v19: word 20 of `varlist'
	local v20: word 21 of `varlist'
	local v21: word 22 of `varlist'
	local v22: word 23 of `varlist'
	local v23: word 24 of `varlist'
	local v24: word 25 of `varlist'
	local v25: word 26 of `varlist'
	local v26: word 27 of `varlist'
	local v27: word 28 of `varlist'
	local v28: word 29 of `varlist'
	local v29: word 30 of `varlist'
	local v30: word 31 of `varlist'
	local v31: word 32 of `varlist'
	local v32: word 33 of `varlist'
	local v33: word 34 of `varlist'
	local v34: word 35 of `varlist'
	local v35: word 36 of `varlist'
	local v36: word 37 of `varlist'
	local v37: word 38 of `varlist'
	local v38: word 39 of `varlist'
	local v39: word 40 of `varlist'
	local v40: word 41 of `varlist'
	
	
	tempvar e
	gen double `e'=0 `if'
	local j 2
	foreach var of varlist `v1' `v2' `v3' `v4' `v5' `v6' `v7' `v8' `v9' `v10' `v11' `v12' `v13' `v14' `v15' `v16' `v17' `v18' `v19' `v20' `v21' `v22' `v23' `v24' `v25' `v26' `v27' `v28' `v29' `v30' `v31' `v32' `v33' `v34' `v35' `v36' `v37' `v38' `v39' `v40' `v41'   {
		replace `e'= `e' + `var'*`at'[1,`j'] `if' 
		local `++j'
	}
	replace `e' = `e' + `at'[1,1] `if'
	replace `e'= 1/(1+exp(`e')) `if' 
	replace `elas'=ln(`e') `if'
end	
